Integration Guide Kawasaki
Note: We strongly recommend that you read the Robot communication overview before this integration guide.
This guide describes the Robot module 1.12.0 for Kawasaki robots. Use it with Bin Picking Studio (BPS) 1.12.
Contents
1 Prerequisites
Kawasaki E-series or F-series robot controller.
The controller must support the AS TCP/IP socket instructions (
TCP_CONNECT,TCP_SEND,TCP_RECV,TCP_LISTEN,TCP_ACCEPT). The Robot module uses them for both connections.A PC with KRTerm (or a USB stick) to load the
.pgfiles.Bin Picking Studio 1.12 on the vision controller.
See the Robot module support matrix for the supported features.
2 Robot controller setup
2.1 Controller configuration
2.1.1 Network configuration
Turn on the robot controller and wait for the system to boot. Open the Menu screen and select the Aux Function option:
In the Aux function menu, select System and Network Settings:
The robot controller has two Ethernet ports. Use Port 1 for communication with Photoneo Bin Picking Studio. Use Port 2 to transfer programs between the PC and the robot controller with KRTerm.
Configure Port 1 for your network. Make sure that the robot controller and the vision controller with Photoneo Bin Picking Studio are on the same subnet.
Configure Port 2 to transfer programs between the PC and the robot controller. Click Next Page, configure the network settings and click the Enter button to confirm.
Restart the robot controller to apply the network settings.
The Robot module uses two TCP connections:
Action Request Client - the robot program connects to the vision controller on port 11003.
Robot State Server - the robot listens on port 11004 and the vision controller connects to it.
2.1.2 Changing the Cartesian origin of the robot
Photoneo Bin Picking Studio requires the origin of the robot at the very bottom of the robot.
On Kawasaki robots, the default origin is in the axis of the second joint. You must move the origin down along the Z axis.
Go to Menu -> Aux Functions -> Advanced Settings -> Base Coordinates.
Set the Z coordinate value from the offset table on the Base frame offsets page.
Warning: A change of the base coordinates can affect the positions that you taught before!
2.2 Robot module installation
2.2.1 Loading the Robot module files
The Robot module is shipped as Photoneo_BPS_Module_1_12_0.zip. It contains:
File |
Content |
|---|---|
|
Core of the module: connection, request and receiving programs, constants ( |
|
Programs you adapt: gripper actions ( |
|
15 example programs, see Example programs. |
|
Short description and version history. |
|
Quick reference (written for module 1.11). |
Load photoneo_common.pg and customer_definitions.pg first, then the example program you want to use (for example basic_application.pg).
You can copy the .pg files to the robot controller directly from a USB stick with the teach pendant. The easiest way, however, is to use the KRTerm tool (download_1, download_2).
Make sure that Port 2 is configured for communication with your PC and that both devices are on the same subnet. You must be able to ping the robot controller from the command line.
Open KRTerm and select COM -> Options to add a new robot controller:
Enter the IP address of Port 2 that you configured on the teach pendant in the previous step. Click the Add button:
Click File -> Set Current Folder and select the folder with the extracted .pg files:
You can now connect to the robot. Make sure that you can ping the robot controller from your PC, then click the Connect button.
If the connection is successful, you see the login prompt shown in the figure below:
The login name is as. After a successful login, you can send commands directly to the robot controller.
To load .pg files to the robot controller, enter the LOAD command as shown in the figure below:
Use the LOAD command to upload all .pg files of the Robot module.
Make sure that all files loaded successfully.
2.2.2 Enabling the autostart of the Robot State Server
The Robot module runs two tasks:
the Action Request Client - your main program, started with Cycle Start,
the Robot State Server - the AS program
autostart.pcfromphotoneo_common.pg. It runs in the background as PC program 1.
To start the Robot State Server on boot, enable the AUTOSTART.PC system switch. The example programs also set it with the line autostart.pc ON.
On the teach pendant, click Menu -> Aux Functions -> Advanced Settings -> System Switch.
Set AUTOSTART.PC to ON. The Robot State Server then starts correctly, also on the first boot.
Restart the robot controller to apply the autostart settings.
Note: Before you continue, make sure that the Robot State Server is running. The PC window on the teach pendant must not be empty - the AUTOSTART program pointer must be visible there.
The robot controller is now configured to work with Bin Picking Studio.
3 Robot module
The Robot module is easy to integrate into existing applications written in the AS language. Your program calls the AS programs (procedures) described below with CALL.
3.1 Robotic API
Note: See Action requests for what each request does on the vision controller side.
3.1.1 Connection procedures
Warning: These procedures are part of photoneo_common.pg and must not be edited!
Procedure |
Description / Usage |
|---|---|
|
Calls Set before the call (global variables): Set in
bp_port = 11003
vc_ip[1] = 192
vc_ip[2] = 168
vc_ip[3] = 0
vc_ip[4] = 80
CALL connect_to_vc (ret_val)
|
|
Closes the connection to the vision controller. |
3.1.2 Communication procedures
Warning: These procedures are part of photoneo_common.pg and must not be edited!
vision_system_i- global variable with the vision system ID. Set it before every request that needs a vision system (marked VS below)..ret_val...- the first or last parameter of each procedure. It receives the result (error code, 0 = OK). The global variableerror_msgalso stores the same value.Only one request can be open at a time. Asynchronous requests (Scan, Trajectory, Trigger scan, Localize on the last scan) only send the request. Receive the response with the matching receiving procedure before you send the next request.
Bin picking requests
Procedure |
ID |
Inputs |
Outputs |
|---|---|---|---|
|
4 |
VS, start and end pose as joint values ( |
error code |
|
4 |
VS, start and end joint pose as strings |
error code |
|
1 |
VS |
send result; receive the response with |
|
- |
- |
result of the Scan, Trigger scan or Localize on the last scan request |
|
2 |
VS |
send result; receive the response with |
|
- |
- |
error code, trajectory and gripper actions (used by |
|
7 |
VS |
error code |
|
8 |
VS |
error code, |
|
3 |
VS |
error code (bin localization) |
|
15 |
|
error code |
|
21 |
VS |
error code, |
|
28 |
VS (the robot pose is taken from the Robot State Server) |
send result; receive the response with |
|
29 |
VS |
error code (synchronous - no |
|
32 |
VS, |
error code |
Calibration requests
Procedure |
ID |
Inputs |
Outputs |
|---|---|---|---|
|
5 |
- (the robot pose is taken from the Robot State Server) |
error code |
|
25 |
solution ID, vision system ID |
error code |
|
26 |
- |
error code |
|
27 |
- |
error code, |
Solution requests
The solution requests have two sets of names. Both sets do the same thing, but the parameter order is different.
Procedure |
ID |
Inputs |
Outputs |
|---|---|---|---|
|
9 |
solution ID |
error code |
|
10 |
solution ID |
error code |
|
11 |
- |
error code |
|
12 |
- |
error code, |
|
13 |
- |
error code, |
Other requests
Procedure |
ID |
Inputs |
Outputs |
|---|---|---|---|
|
100 |
- |
error code |
3.1.3 Bin picking procedures
Note: These procedures are in customer_definitions.pg. Adapt them to your application.
Procedure |
Description / Usage |
|---|---|
|
Your gripper “attach” action (for example |
|
Your gripper “detach” action. Called by |
|
Custom gripper actions. Called by |
|
Executes the received bin picking trajectory ( Warning: If you use several Start poses (for example one per vision system), make sure that the robot is at the correct one. |
|
Motion settings ( |
3.1.4 Auxiliary procedures
Warning: These procedures are part of photoneo_common.pg and must not be edited!
Procedure |
Description / Usage |
|---|---|
|
Restarts the Robot State Server ( |
|
Sets the brand ID, request IDs, error codes and network timeouts. Called by |
|
Returns the name of an error code (for example |
|
Returns the name of a request ID. |
3.1.5 Info data
The module stores the values returned by the requests in global variables. See Info data for the meaning of each key and the request that returns it. init_consts resets the values to -1 at every connect_to_vc.
Key |
Variable |
Unit in robot |
Returned by |
|---|---|---|---|
1 |
|
index |
|
2 |
|
index |
|
3 |
|
index |
|
4 |
|
mm |
|
5 |
|
mm |
|
6 |
|
rad |
|
7 |
|
index |
|
8 |
|
mm |
|
9 |
|
rad |
|
10 |
|
µm |
|
11 |
|
ID |
|
12 |
|
count |
|
13 |
|
count |
|
14 |
|
1 / 0 |
|
pose |
|
POINT ( |
|
pose |
|
POINT ( |
|
3.1.6 Global variables
Besides the Info data variables, the module uses these global variables:
Variable |
Meaning |
|---|---|
|
IP address and port of the vision controller. Set by your program. |
|
Vision system ID used by the next request. Set by your program. |
|
Result of the last procedure (same value as |
|
TRUE after a trajectory was received, FALSE after |
|
Received trajectories (joint values in deg), gripper actions and their order. Used by |
|
ID of the request waiting for a response (-1 = none). |
|
Connection attempts and timeouts in seconds (set in |
|
Robot State Server port (11004) and timeouts (set in |
|
TRUE when the client / state server socket is closed. |
3.1.7 Error codes
init_consts defines these error code constants. See Error codes for their meaning and troubleshooting. get_error returns the name of a code.
AS constant |
Code |
AS constant |
Code |
|---|---|---|---|
|
0 |
|
450 |
|
1 |
|
451 |
|
2 |
|
452 |
|
3 |
|
453 |
|
4 |
|
454 |
|
5 |
|
455 |
|
7 |
|
457 |
|
8 |
|
458 |
|
200 |
|
459 |
|
201 |
|
460 |
|
202 |
|
461 |
|
203 |
|
462 |
|
218 |
|
463 |
|
219 |
|
464 |
|
220 |
|
465 |
|
221 |
|
466 |
|
222 |
|
467 |
|
255 |
|
468 |
- |
- |
|
469 |
Other codes sent by the vision controller (for example calibration point errors 100-134) are returned as numbers.
3.2 Example programs
The folder AS/example_programs contains these programs. Each one sets vc_ip / bp_port, connects and shows one feature with basic error handling. The error handling in the examples is only a demonstration - adapt it to your application.
File (AS program) |
Purpose |
|---|---|
|
Basic bin picking loop with one vision system. Listing below. |
|
Two vision systems, each with its own Start/End poses. They alternate in every cycle. |
|
Switches between solution 1 and 2 after each pick ( |
|
Switches between scene states 1 and 2 after each pick ( |
|
Switches between bounding box 1 and 2 after each pick ( |
|
Polls the vision system status ( |
|
Gets the object pose ( |
|
Bin picking with the sensor on the robot; |
|
Hand-eye MultiView: trigger scans at fixed poses ( |
|
Hand-eye MultiView: trigger scans along a |
|
Minimal Trigger scan example. |
|
Vision system 1 scans, vision system 2 localizes on the same scan ( |
|
Connects and sends Communication check requests ( |
|
Automatic calibration with 9 poses: start, add points, save, stop. See Calibration example. |
|
Calibration with 9 poses. It first checks that all poses were retaught. It sends start/save/stop only if |
3.2.1 Basic bin picking example
The program connects to the vision controller, initializes one vision system and then picks in a loop. In each cycle it waits for the scan and requests a trajectory. It moves to #pho_start while the vision controller calculates the trajectory. Then it receives the trajectory, picks, moves home and starts the next scan before placing. If no part is found or planning fails, it moves home and scans again.
Name: basic_application.pg (folder example_programs)
.PROGRAM basic_application ()
; *******************************************************************
;
; Program: basic_application
; Comment: Basic bin picking template with single vision system
; Author: Photoneo s.r.o.
;
; Date: 17/04/2026
;
; *******************************************************************
;
; ==============================================================================
; BASIC BIN PICKING
; ==============================================================================
; This is a basic bin picking template.
; Program executes picking in a continuous loop.
; Reteach #pho_home, #pho_start and #pho_end for your application.
; Set the IP address of the Vision Controller below.
; Adapt the gripper operations in customer_definitions.pg.
; ==============================================================================
;
;// Enable State Server to start on boot
autostart.pc ON
;// Set IP address of the Vision Controller
bp_port = 11003
vc_ip[1] = 192
vc_ip[2] = 168
vc_ip[3] = 0
vc_ip[4] = 80
;// Connect to the Vision Controller
CALL connect_to_vc (ret_val)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// Set Vision System ID
vision_system_i = 1
;// Initialize the vision system with start and end bin picking poses
;// Start/end poses are used in trajectory planning on the VC side
CALL initialize_req (ret_val, #pho_start, #pho_end)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// Open gripper before starting
CALL grip_detach
;// Set robot speed
SPEED 10 ALWAYS
;// Move to Home pose - robot must not occlude the scanning area
JMOVE #pho_home
BREAK
;// Trigger the first scan, localization and path planning
CALL scan_req (ret_val)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// Initial wait to allow the VC to finish the first trajectory calculation
TWAIT 10
;// ==================== MAIN LOOP =============================================
WHILE (TRUE) DO
main_start:
;// Wait until the scan and trajectory calculation are complete
CALL wait_for_scan (ret_val)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// Request a trajectory from the VC (non-blocking send)
CALL traj_req (ret_val)
;// Check that the request was sent successfully
IF (ret_val <> ok) THEN
GOTO quit
END
;// Move to the bin picking start pose while the VC calculates the trajectory
;// This overlaps robot motion with VC computation to save cycle time
JMOVE #pho_start
;// Receive the trajectory response (blocks until VC responds)
CALL traj_recv (ret_val)
;// If no part was found or planning failed, go back and request a new scan
IF (ret_val == planning_failed) OR (ret_val == no_part_found) THEN
;// Move back to Home pose before rescanning
JMOVE #pho_home
BREAK
;// Request a new scan, localization and path planning
CALL scan_req (ret_val)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// Restart the main loop
GOTO main_start
END
;// If another error occurred, abort
IF (ret_val <> ok) THEN
GOTO quit
END
;// Execute bin picking routine (robot follows planned trajectory)
CALL pick_part
;// Move back to Home pose after picking
JMOVE #pho_home
BREAK
;// Trigger the next scan immediately so the VC can calculate the next
;// trajectory while the robot is placing the part (parallel execution)
CALL scan_req (ret_val)
;// Check return value, abort in case of failure
IF (ret_val <> ok) THEN
GOTO quit
END
;// ==================== PLACING ============================================
;// Add placing commands here - reteach positions for your robot and workcell
CALL grip_detach
;// =========================================================================
END
;// End of the MAIN LOOP
quit:
;// Disconnect from the Vision Controller
CALL close_socket
.END
3.2.2 Calibration example
calibration.pg runs an automatic calibration from the robot. The robot pose of each point comes from the Robot State Server, so the Robot State Server must be running.
Before you run the program:
teach
#default_pose(intermediate pose between the calibration poses) and#calib_1..#calib_9,set
sol_idto the solution andvision_system_ito the vision system to calibrate,deploy the solution in Bin Picking Studio.
The program does these steps:
calib_start_req(ret_val, sol_id, vision_system_i)- starts the calibration.For each of the 9 poses:
JMOVE #default_pose,JMOVE #calib_N,BREAK,calib_add_req(ret_val).calib_save_req(ret_val)- saves the result;camera_poseandcalib_accare filled.calib_stop_req(ret_val)- ends the calibration.
On any error, it jumps to quit, closes the socket and stops. Run it step by step in MANUAL mode and check that the robot does not collide between the poses.
calibration_expert.pg does the same, with two differences. It first stops (HALT) at #default_pose so that you can confirm the poses, and it checks that no pose still has its default value. It sends start/save/stop only if calib_auto = TRUE. Otherwise, start and save the calibration in Bin Picking Studio.
3.3 Error handling
Every request procedure returns its result in .ret_val... and in error_msg. Check the result after each synchronous request and after each receiving procedure (wait_for_scan, traj_recv). See Error codes for the list of codes.
What the module does when a problem occurs:
Connection fails -
connect_to_vctriesconnect_atttimes and returns 3 (communication error).No data within the timeout (
tout_recv/tout_send, 60 s) - the procedure returns 5 (timeout). Other socket errors return 3. After 3 or 5, the request stays open. Callconnect_to_vcagain to reconnect.Logic errors - the module prints a message, closes the socket and stops the program (
HALT). This happens when:a request is sent before the previous response was received,
a receiving procedure is called for the wrong request,
the response does not match the request,
a trajectory has a wrong checksum,
pick_partis called without a new trajectory.
Messages - the client prints messages with the prefix
BP_CLIENT:and the state server with the prefixSTATE_SERVER:. You can see them on the teach pendant under Menu -> Keyboard.
3.4 Robot State Server
The Robot State Server is the AS program autostart.pc in photoneo_common.pg. It runs as PC program 1. The AUTOSTART.PC switch starts it on boot (see 2.2.2).
It listens on port 11004 (
state_port) and waits for the vision controller to connect.It sends the brand ID. Then it sends two messages in a loop: the joint positions (
HERE #jp, deg) and the TCP pose (HERE tcp, X, Y, Z in mm and O, A, T in deg).After each pair of messages it waits 0.025 s (
TWAIT), so it sends about 40 states per second at most.If sending fails, it closes the connection and starts listening again.
Bin Picking Studio uses these states as the robot pose for calibration (calib_add_req), hand-eye scans and Trigger scan. Use ss_check to restart the Robot State Server.
4 Running the basic bin picking example program
4.1 Prerequisites
Before you run the Basic bin picking example, make sure that:
a fully configured BPS solution with a single vision system is ready for deployment,
the robot controller is configured as described in the chapter Robot controller setup of this integration guide,
the Bin Picking Studio network settings are configured,
the gripper procedures are implemented (optional - without them, the robot does not actually pick the object),
the placing procedure is implemented.
4.2 Bin picking routine execution settings
customer_definitions.pg contains the programs traj_1_params .. traj_4_params. pick_part calls traj_X_params before trajectory number X of the bin picking routine. These programs set DECEL and ACCURACY for the following motions. Add SPEED / ACCEL if needed.
The module ships four programs because a grasping method has 4 trajectories by default. pick_part supports up to 10 trajectories. If your grasping method has more than 4, add traj_5_params, traj_6_params and so on.
4.3 Reteaching the robot poses
An important step of the bin picking configuration is to teach the Home, Start and End poses:
Home pose - the robot is outside the scanning area.
Start pose - the robot gripper is approximately above the center of the bin.
End pose - similar to the Start pose, or slightly shifted towards the placing area. Do not put the End pose too far from the bin. This can affect the path planning (longer planning time, planning errors, etc.).
The Basic bin picking example program uses the following poses (all joint values):
#pho_home- Home pose#pho_start- Start pose#pho_end- End pose
Also set vc_ip[1..4] to the IP address of the vision controller.
4.4 Runtime
Deploy your BPS solution. The Action Request Client status on the BPS Deployment page must be DISCONNECTED (from the Action Request Server).
First, select the program to run. Click the yellow program rectangle on the teach pendant touch screen:
Select Directory to open the program list:
Find and select the basic_application program:
When the program is ready, hold the A key and press the RUN/HOLD key on the teach pendant. The RUN status appears in the top right corner:
Turn on the motor power: hold the A key and press the MOTOR_ON/JOG key. You hear the motor brakes release, and the MOTOR status appears next to the RUN status in the top right corner.
Start the program on the robot controller: hold the A key and press the CYCLE START/CONT key. The CYCLE status turns green in the top right corner:
The Action Request Client status on the Deployment page changes to CONNECTED.
Press Menu -> Keyboard on the teach pendant. You see text output as shown in the figure below. This shows that the Action Request Client works correctly.
When the trajectory to the first localized object is ready, the robot starts to move.
NOTE: Be ready to stop the robot motion immediately. We strongly recommend that you reduce the speed to 10% of maximum during the first bin picking tests.
5 Migration guide
This chapter lists the Kawasaki-specific changes between versions. For the current version see 5.1 BPS 1.11.x -> BPS 1.12.x and the general migration guide 1.11.x -> 1.12.x. Every migration requires the Robot module update.
5.1 BPS 1.11.x -> BPS 1.12.x
Update the Robot module. Main programs written for 1.11 still work.
New brand ID
KAWASAKI/1.12.0XXXXXXXXX.Info data: each message now carries one value. The module stores it by its key (1-14), see Info data.
New Info data variables:
nn_label(key 7),max_z_height(key 8),pho_tilt(key 9, rad).
See the general migration guide 1.11.x -> 1.12.x for the protocol changes.
5.2 Robot module update
Back up the programs in
customer_definitions.pgthat you changed (gripper programs,traj_X_params).Remove all old module programs except your main program.
Load the new
photoneo_common.pgandcustomer_definitions.pg.Copy your changes into the new programs.
Check the API changes in the new version and update your main program if needed.
6 Troubleshooting
If you see the Open Socket Error shown in the figure below, the previous connection to Bin Picking Studio was not closed correctly.
Run the close_socket() program to close the previous session correctly:
If the vision controller does not show the robot state, check that autostart.pc is running (PC window on the teach pendant). Run ss_check to restart it.
7 Version and brand ID
Robot module version: 1.12.0
Brand ID (sent after connecting, by both the client and the Robot State Server):
KAWASAKI/1.12.0XXXXXXXXX